﻿using B.S.Shop.Application.Command;
using B.S.Shop.Domain;
using B.S.Shop.ErrorCode;
using B.S.Shop.Infartructrue.Interfaces;
using MediatR;

namespace B.S.Shop.Application.Commandhandler
{
    public class BossQueryCommandHandler : IRequestHandler<BossQueryCommand, APIResult<List<BossClass>>>
    {
        public BossQueryCommandHandler(IBaseRepository<BossClass> bossRepository)
        {
            BossRepository = bossRepository;
        }

        public IBaseRepository<BossClass> BossRepository { get; }

        public async Task<APIResult<List<BossClass>>> Handle(BossQueryCommand request, CancellationToken cancellationToken)
        {
            var path = BossRepository.GetAll().ToList();
            return new APIResult<List<BossClass>>
            {
                Code = ResultCode.success,
                Mag = "",
                data = path
            };
        }
    }
}
